{% extends 'base.html' %}
{% load static %}
{% block title %}
    天天生鲜-首页
{% endblock %}

{% block content %}
    {% include 'includes/search.html' %}

    <div class="navbar_con">
        <div class="navbar">
            <h1 class="fl">全部商品分类</h1>
            <ul class="navlist fl">
                <li><a href="">首页</a></li>
                <li class="interval">|</li>
                <li><a href="">手机生鲜</a></li>
                <li class="interval">|</li>
                <li><a href="">抽奖</a></li>
            </ul>
        </div>
    </div>

    <div class="center_con clearfix">
        <ul class="subnav fl">
            {% for type in type_list %}
                <li><a href="#{{ type.logo }}" class="{{ type.logo }}">{{ type.name }}</a></li>
            {% endfor %}
        </ul>
        <div class="slide fl">
            <ul class="slide_pics">
                {% for banner in banner_list %}
                    <li><img src="/media/{{ banner.image }}" alt="幻灯片"></li>
                {% endfor %}
            </ul>
            <div class="prev"></div>
            <div class="next"></div>
            <ul class="points"></ul>
        </div>
        <div class="adv fl">
            {% for promotion in promotion_list %}
                <a href="#"><img src="/media/{{ promotion.image }}"></a>
            {% endfor %}
        </div>
    </div>

    {% for type in type_list %}
        {% if type.index_type.count != 0 %}
            <div class="list_model">
                <div class="list_title clearfix">
                    <h3 class="fl" id="{{ type.logo }}">{{ type.name }}</h3>
                    <div class="subtitle fl">
                        <span>|</span>
                        {% for item in type.index_type.all %}
                            {% if item.display_type == 0 %}
                                <a href="#">{{ item.sku.name }}</a>
                            {% endif %}
                        {% endfor %}
                    </div>
                    <a href="{% url 'goods:g_list' type.pk %}" class="goods_more fr" id="fruit_more">查看更多 ></a>
                </div>
                <div class="goods_con clearfix">
                    <div class="goods_banner fl"><img src="/media/{{ type.image }}"></div>
                    <ul class="goods_list fl">
                        {% for item in type.index_type.all %}
                            {% if item.display_type == 1 %}
                                <li>
                                    <h4><a href="{% url 'goods:g_detail' item.sku.pk %}">{{ item.sku.name }}</a></h4>
                                    <a href="{% url 'goods:g_detail' item.sku.pk %}"><img src="/media/{{ item.sku.image }}"></a>
                                    <div class="prize">¥ {{ item.sku.price }}</div>
                                </li>
                            {% endif %}
                        {% endfor %}
                    </ul>
                </div>
            </div>
        {% endif %}
    {% endfor %}


{% endblock %}
{% block js %}
    {{ super }}
    <script type="text/javascript">
        BCSlideshow('focuspic');
        var oFruit = document.getElementById('fruit_more');
        var oShownum = document.getElementById('show_count');

        var hasorder = localStorage.getItem('order_finish');

        if (hasorder) {
            oShownum.innerHTML = '2';
        }

        oFruit.onclick = function () {
            window.location.href = 'list.html';
        }
    </script>
{% endblock %}

